package controller

import (
	"beergo/app/sys/models"
	"beergo/lib/tool"
	"github.com/beego/beego/v2/server/web"
)

func  (this BaseController) GetUser() models.User {
	tokenKey := web.AppConfig.DefaultString("beer::AuthToken","")
	xt := this.Ctx.Request.Header.Get(tokenKey)
	repUser := models.UserRepository{}
	user := repUser.FindOneBy(tool.StringKeyMap{"token": xt}, nil)
	return user
}

func  (this BaseController) GetAdminUser() models.User {
	tokenKey := web.AppConfig.DefaultString("beer::AuthTokenAdmin","")
	xt := this.Ctx.Request.Header.Get(tokenKey)
	repUser := models.UserRepository{}
	user := repUser.FindOneBy(tool.StringKeyMap{"token": xt}, nil)
	return user
}
